package com.fqy.gmall.item.all.controller;

import com.fqy.gmall.common.result.Result;
import com.fqy.gmall.item.client.ItemFeignClient;
import com.fqy.gmall.model.product.SkuInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.Map;

/**
 * User: fqy
 * Date: 2021/9/18
 * Time: 4:54
 * Describe:
 */
@Controller
public class ItemController {
    @Autowired
    private ItemFeignClient itemFeignClient;
    //  https://item.jd.com/100016034400.html
    //  http://item.gmall.com/2.html//4
    //  编写控制器
    @RequestMapping("{skuId}.html")
    public String getItem(@PathVariable Long skuId, Model model){
        //  获取数据
        Result<Map> result = itemFeignClient.getItemBySkuId(skuId);
        //  存储数据
        model.addAllAttributes(result.getData());
        //  返回的视图名称
        return "item/index";
    }

}
